package kylintool.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class ThreadMain {
	public static void main(String[] args) {
	Thread thread1 = new Thread(new RunnableT(),"RunnableT1");
	thread1.getId();
	System.out.println(thread1.getName()+thread1.getId()+thread1.isAlive());
	thread1.start();
	System.out.println(thread1.getName()+thread1.isAlive());
//	Future sf = new Future();
	Callable<String> callable = new CallableT();
	FutureTask<String> ftask  = new FutureTask<String>(callable);
	ftask.run();
	try {
		Object obj = ftask.get(5000, TimeUnit.MILLISECONDS);
		System.out.println(obj);
	} catch (InterruptedException | ExecutionException | TimeoutException e) {
		e.printStackTrace();
	}
}
}
